import 'dart:developer';

import 'package:flutter/services.dart';
import 'package:kmxy_base/base/base_package.dart';
import 'package:kmxy_base_example/page/page_manage_package.dart';

abstract class ListPageState extends BasePageState<ListPage> {
  /// 必须持有一个list集合
  List<String> dataList = [];
  late GridListViewController gridListViewController;

  onGridListViewCreated(GridListViewController controller) {
    gridListViewController = controller;
    // onRefresh();
  }

  onRefresh() async {
    setState(() {
      dataList = ['sss', 'sdafads', 'dsfdasf'];
    });
    gridListViewController.onFinishRefresh();
  }

  onLoading() async {
    setState(() {
      dataList.addAll(['sss', 'sdafads', 'dsfdasf']);
    });
    gridListViewController.onFinishLoading(false);
  }

  @override
  initData() async {
    await SystemChrome.setPreferredOrientations(
        [DeviceOrientation.landscapeLeft]);
  }

  @override
  destroyData() async {
    await SystemChrome.setPreferredOrientations([DeviceOrientation.portraitUp]);
  }

  mapPickerMore() {
    DialogFactory.pickerMapMore(context, tempList, 'lrnm',
        onConfirm: (List selectList, Map selectData) {
      log(selectList.toString());
      log(selectData.toString());
    }, onCancel: () {});
  }

  List tempList = [
    {
      "lrnm": "河流",
      "lrtp": "0",
      "children": [
        {
          "lrtp": "0",
          "lrcd": "001",
          "lrnm": "测试但是捡垃圾大垃圾袋老司机阿拉",
          "children": [
            {"lrtp": "1", "lrcd": "SK001", "lrnm": "测试水库222", "children": null},
            {"lrtp": "2", "lrcd": "SK002", "lrnm": "测试水库", "children": null}
          ]
        },
        {
          "lrtp": "0",
          "lrcd": "001",
          "lrnm": "测试",
          "children": [
            {"lrtp": "1", "lrcd": "SK001", "lrnm": "测试水库222", "children": null},
            {"lrtp": "2", "lrcd": "SK002", "lrnm": "测试水库", "children": null}
          ]
        }
      ]
    },
    {
      "lrnm": "水库",
      "lrtp": "1",
      "children": [
        {
          "lrtp": "1",
          "lrcd": "SK001",
          "lrnm": "测试水库",
          "children": [
            {"lrtp": "1", "lrcd": "SK001", "lrnm": "测试水库", "children": null},
            {"lrtp": "2", "lrcd": "SK002", "lrnm": "测试水库3121", "children": null}
          ]
        },
        {"lrtp": "1", "lrcd": "sk-003", "lrnm": "赵子河水库", "children": null},
        {"lrtp": "1", "lrcd": "sk-001", "lrnm": "升钟水库", "children": null},
        {"lrtp": "1", "lrcd": "sk-002", "lrnm": "王大湾水库", "children": null},
        {"lrtp": "1", "lrcd": "sk-004", "lrnm": "龙台山水库", "children": null},
        {"lrtp": "1", "lrcd": "sk-005", "lrnm": "应家沟水库", "children": null},
        {"lrtp": "1", "lrcd": "sk-006", "lrnm": "莲花湖", "children": null},
        {"lrtp": "1", "lrcd": "sk-007", "lrnm": "九龙潭", "children": null},
        {"lrtp": "1", "lrcd": "sk-008", "lrnm": "青龙湖", "children": null},
        {"lrtp": "1", "lrcd": "111", "lrnm": "测试水库-浸润线", "children": null},
        {"lrtp": "1", "lrcd": "sk-009", "lrnm": "八尔湖", "children": null},
        {"lrtp": "1", "lrcd": "SK1112", "lrnm": "大屯海水库", "children": null},
        {"lrtp": "1", "lrcd": "SK002", "lrnm": "测试水库2", "children": null}
      ]
    },
    {
      "lrnm": "渠道",
      "lrtp": "2",
      "children": [
        {"lrtp": "2", "lrcd": "QD_I9PQ", "lrnm": "白七斗渠", "children": null},
        {"lrtp": "2", "lrcd": "QD_I26E", "lrnm": "南溪分支渠", "children": null},
        {"lrtp": "2", "lrcd": "QD_I9DV", "lrnm": "白塔斗渠", "children": null},
        {"lrtp": "2", "lrcd": "QD_IXBZ", "lrnm": "永清斗渠", "children": null},
        {"lrtp": "2", "lrcd": "QD_IXVR", "lrnm": "中心分支渠", "children": null},
        {"lrtp": "2", "lrcd": "QD_IXJG", "lrnm": "彭城分支渠", "children": null},
        {"lrtp": "2", "lrcd": "QD_IX7B", "lrnm": "柏垭分支渠", "children": null},
        {"lrtp": "2", "lrcd": "QD_IXSU", "lrnm": "兴隆分支渠", "children": null},
        {"lrtp": "2", "lrcd": "QD_IXWP", "lrnm": "观音分支渠", "children": null},
        {"lrtp": "2", "lrcd": "QD_IZYK", "lrnm": "窑场分支渠", "children": null},
        {"lrtp": "2", "lrcd": "QD_IZ3E", "lrnm": "碧龙分支渠", "children": null},
        {"lrtp": "2", "lrcd": "QD_IZ7I", "lrnm": "龙大山分支渠", "children": null},
        {"lrtp": "2", "lrcd": "QD_IZD3", "lrnm": "梅子垭分支渠", "children": null},
        {"lrtp": "2", "lrcd": "QD_IZQC", "lrnm": "梨树垭提灌分支渠", "children": null},
        {"lrtp": "2", "lrcd": "QD_IDU5", "lrnm": "马鞍分支渠", "children": null},
        {"lrtp": "2", "lrcd": "QD_ID5R", "lrnm": "共兴分支渠", "children": null},
        {"lrtp": "2", "lrcd": "QD_ID9D", "lrnm": "大村沟分支渠", "children": null},
        {"lrtp": "2", "lrcd": "QD_ID26", "lrnm": "东太分支渠", "children": null},
        {"lrtp": "2", "lrcd": "QD_IDWS", "lrnm": "李家分支渠", "children": null},
        {"lrtp": "2", "lrcd": "QD_I5KS", "lrnm": "金源斗渠", "children": null},
        {"lrtp": "2", "lrcd": "QD_I742", "lrnm": "扶黄斗渠", "children": null},
        {"lrtp": "2", "lrcd": "QD_I5Z7", "lrnm": "大河斗渠", "children": null},
        {"lrtp": "2", "lrcd": "QD_I58B", "lrnm": "蓬镇斗渠", "children": null},
        {"lrtp": "2", "lrcd": "QD_IPB4", "lrnm": "金台斗渠", "children": null},
        {"lrtp": "2", "lrcd": "QD_IPUJ", "lrnm": "青龙湖提灌渠", "children": null},
        {"lrtp": "2", "lrcd": "QD_IP92", "lrnm": "八尔湖充水渠", "children": null},
        {"lrtp": "2", "lrcd": "QD_IP23", "lrnm": "荆溪斗渠", "children": null},
        {"lrtp": "2", "lrcd": "QD_I7GV", "lrnm": "马市铺斗渠", "children": null},
        {"lrtp": "2", "lrcd": "QD_I7T8", "lrnm": "永丰斗渠", "children": null},
        {"lrtp": "2", "lrcd": "QD_I94P", "lrnm": "光华斗渠", "children": null},
        {"lrtp": "2", "lrcd": "QD_I7CB", "lrnm": "车龙斗渠", "children": null},
        {"lrtp": "2", "lrcd": "QD_I7A7", "lrnm": "占山斗渠", "children": null},
        {"lrtp": "2", "lrcd": "QD_ICB5", "lrnm": "观凤斗渠", "children": null},
        {"lrtp": "2", "lrcd": "QD_ICY2", "lrnm": "中凤斗渠", "children": null},
        {"lrtp": "2", "lrcd": "QD_ICUZ", "lrnm": "新华斗渠", "children": null},
        {"lrtp": "2", "lrcd": "QD_IC9S", "lrnm": "石龙斗渠", "children": null},
        {"lrtp": "2", "lrcd": "QD_IC2B", "lrnm": "万年斗渠", "children": null},
        {"lrtp": "2", "lrcd": "QD_IC8A", "lrnm": "老观斗渠", "children": null},
        {"lrtp": "2", "lrcd": "QD_I96Y", "lrnm": "度门斗渠", "children": null},
        {"lrtp": "2", "lrcd": "QD_I8EM", "lrnm": "左分干渠", "children": null},
        {"lrtp": "2", "lrcd": "QD_IETK", "lrnm": "西蓬分干渠", "children": null},
        {"lrtp": "2", "lrcd": "QD_IEJ5", "lrnm": "西南分干渠", "children": null},
        {"lrtp": "2", "lrcd": "QD_IEI8", "lrnm": "盐溪分干渠", "children": null},
        {"lrtp": "2", "lrcd": "QD_IEX6", "lrnm": "南充干渠", "children": null},
        {"lrtp": "2", "lrcd": "QD_IEAP", "lrnm": "西充干渠", "children": null},
        {"lrtp": "2", "lrcd": "QD_542U", "lrnm": "右总干渠", "children": null},
        {"lrtp": "2", "lrcd": "QD_I82W", "lrnm": "五龙支渠", "children": null},
        {"lrtp": "2", "lrcd": "QD_ISQ3", "lrnm": "华光支渠", "children": null},
        {"lrtp": "2", "lrcd": "QD_I25R", "lrnm": "群乐分支渠", "children": null},
        {"lrtp": "2", "lrcd": "QD_I2ZG", "lrnm": "蒙升分支渠", "children": null},
        {"lrtp": "2", "lrcd": "QD_I28G", "lrnm": "群德分支渠", "children": null},
        {"lrtp": "2", "lrcd": "QD_ISGJ", "lrnm": "龙凤分支渠", "children": null},
        {"lrtp": "2", "lrcd": "QD_ISYK", "lrnm": "大河坝分支渠", "children": null},
        {"lrtp": "2", "lrcd": "QD_IS3Z", "lrnm": "复兴分支渠", "children": null},
        {"lrtp": "2", "lrcd": "QD_IS59", "lrnm": "三元分支渠", "children": null},
        {"lrtp": "2", "lrcd": "QD_ISXV", "lrnm": "大观分支渠", "children": null},
        {"lrtp": "2", "lrcd": "QD_IS2I", "lrnm": "木老分支渠", "children": null},
        {"lrtp": "2", "lrcd": "QD_I2U7", "lrnm": "高农分支渠", "children": null},
        {"lrtp": "2", "lrcd": "QD_IAYE", "lrnm": "石河支渠", "children": null},
        {"lrtp": "2", "lrcd": "QD_IA32", "lrnm": "大桥支渠", "children": null},
        {"lrtp": "2", "lrcd": "QD_IACV", "lrnm": "定水支渠", "children": null},
        {"lrtp": "2", "lrcd": "QD_IA2F", "lrnm": "流马支渠", "children": null},
        {"lrtp": "2", "lrcd": "QD_IAQU", "lrnm": "盘龙支渠", "children": null},
        {"lrtp": "2", "lrcd": "QD_I8RT", "lrnm": "石楼分支渠", "children": null},
        {"lrtp": "2", "lrcd": "QD_I8KA", "lrnm": "武胜支渠", "children": null},
        {"lrtp": "2", "lrcd": "QD_I8C4", "lrnm": "李渡支渠", "children": null}
      ]
    }
  ];
}
